var elasticsearch = require('elasticsearch');

var e_client = new elasticsearch.Client({
    host: 'localhost:9200',
    log: 'trace'
});

e_client.indices.create({index: 'messages'}, function (err, resp) {
    e_client.indices.putMapping({
        index: 'messages',
        type: 'message',
        body:{ 
            properties: {
                "@timestamp" : {
                    type: 'date',
                    format: 'dateOptionalTime'
                },
                email: {
                    type: 'string',
                    index: 'not_analyzed'
                },
                company: {
                    type: 'string',
                    index: 'not_analyzed'
                },
                user: {
                    type: 'string',
                    index: 'not_analyzed'
                },
                message: {
                    type: 'string'                
                },
                category: {
                    type: 'string',
                    index: 'not_analyzed'
                }
            }
        }
    }, function () {
        process.exit(0);
    });
});

